﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace Test_2D
{
    class MyFunc
    {
        //画出元件的图片
        public static void drawCom(PictureBox picbox, Component com)
        {
            picbox.Width = com.Width + 2;
            picbox.Height = com.Height + 2;
            picbox.BackgroundImage = com.Image;
        }


        //画出元件的图片
        public static void drawCom1(PictureBox picbox, Component com)
        {
            picbox.Width = com.Width + 2;
            picbox.Height = com.Height + 2;
            Graphics g = picbox.CreateGraphics();
            g.Clear(Color.White);
            g.DrawImage(com.Image, 1, 1);
        }


//文本框验证
        //必须为正整数
        public static bool isDigit(string str)
        {
            return Regex.IsMatch(str, @"^\+?[1-9][0-9]*$");
        }
        /*
        private void listView1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
                dragForm = true;
            //df = new DragForm();
            //df.BackgroundImage = cur_com.Image;
            //ShowWindow(df.Handle, 4);
        }

        //列表框事件
        private void listView1_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragForm && listView1.SelectedItems.Count != 0)
            {
                if (df == null)
                {
                    df = new DragForm();
                    df.mouse_x = e.X;
                    df.mouse_y = e.Y;
                    cur_com = (Component)listView1.SelectedItems[0].Tag;

                    df.Location = new Point(Control.MousePosition.X - cur_com.width / 2, Control.MousePosition.Y - cur_com.height / 2);
                    df.BackgroundImage = cur_com.Image;
                    df.Size = new Size(cur_com.width + 2, cur_com.height + 2);
                    df.Show(); this.Focus();// ////ShowWindow(df.Handle, 4);
                    df.Capture = true;
                }
                //DoDragDrop(cur_com, DragDropEffects.Copy);
                //Point screenPoint = Control.MousePosition;
                //mouse_x = screenPoint.X;
                //mouse_y = screenPoint.Y;
                //df.Size = new Size(cur_com.width, cur_com.height);
                //df.Location = new Point(Control.MousePosition.X - cur_com.width / 2, Control.MousePosition.Y - cur_com.height / 2);
            }
        }

        private void listView1_MouseUp(object sender, MouseEventArgs e)
        {
            dragForm = false;
            if (df != null)
            {
                df.Dispose();
                df = null;
            }

        }
         * */
    }
}
